home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / cd_lib / src / cdr_tsek.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-08  |  1.2 KB  |  55 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include "define.h"
  5.  
  6. #ifdef DEBUG
  7. main(int argc, char *argv[])
  8. {
  9.     struct TIMEADRS time;
  10.     
  11.     if (argc > 1) {
  12.         printf("input is %s\n", argv[1]);
  13.         time.min = (u_char) atoi(argv[1]);
  14.         time.sec = 0;
  15.         time.frame = 0;
  16.         printf("Seek %d分\n", time.sec);
  17.         printf("return is %x\n", cdr_tseek(0, &time));
  18.     }
  19. }
  20. #endif
  21.  
  22. /* 指定位置へのシーク(時間指定) */
  23. /*
  24.  * decice_no:   device number (Towns CD-ROM -> 0)
  25.  * time: 時間
  26.  * return: 0 -> 正常終了, 0以外 -> エラー
  27.  */
  28. int cdr_tseek(int device_no, struct TIMEADRS *time)
  29. {
  30.     union REGS reg;
  31.     
  32.     if (time == NULL) {
  33.         return -1;
  34.     }
  35.     reg.h.ah = 0x14;
  36.     reg.h.al = (0xC0 | (u_char) device_no);
  37.     reg.x.cx = 0x0000;
  38.     reg.h.cl = (u_char) time->min;    /* 分 */
  39.     reg.h.dh = (u_char) time->sec;    /* 秒 */
  40.     reg.h.dl = (u_char) time->frame;    /* フレーム */
  41.  
  42.     int86(0x93, ®, ®);
  43.     
  44.     if (reg.h.ah == 0) {
  45.         return 0;
  46.     } else if (reg.h.ah == 0x02) {   /* device number error */
  47.         return DEVERR;
  48.     } else if (reg.h.ah == 0x10) {   /* cd-da plaing */
  49.         return DEVPLY;          
  50.     } else {                         /* (reg.h.ah == 0x80) hard ware error */
  51.         return reg.x.cx;
  52.     }
  53. }
  54.  
  55.